/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * input.java
 *
 * Created on 13 Apr 14, 15:09:08
 */
package skripsiar;
import javax.swing.table.DefaultTableModel;
import javax.swing.JOptionPane;
import javax.swing.JFrame;
import java.sql.*;

/**
 *
 * @author ACER ASPIRE 4741Z
 */
public class input extends javax.swing.JFrame {

    private Connection con;
    private String[][] dataTable;
    private Database database;
    private String[] header2 = {"Nomer Ujian", "Nama Peserta", "Program studi 1", "Program studi 2"};
    private String tahun = "";
    
       
    
    
        public input() {
         KonekDB();
         prepare();
         initComponents();   
    }

     public void KonekDB() {
        try {
            Class.forName("com.mysql.jdbc.Driver");
            con = DriverManager.getConnection("jdbc:mysql://localhost:3306/skripsi", "root", "");
            System.out.println("Koneksi ke MySQL server berhasil");
        } catch (ClassNotFoundException eclass) {
            System.out.println("Driver tdk tersedia");
        } catch (SQLException esql) {
            System.out.println(esql.getMessage());
        }
    }
   
     public String getTahun() {
        int combo = jComboBox1.getSelectedIndex();
        if (combo == 0) {
            return "";
        }
        if (combo == 1) {
            return "17094";
        }
        if (combo == 2) {
            return "17104";
        }
        if (combo == 3) {
            return "17114";
        }
        if (combo == 4) {
            return "17124";
        }
        if (combo == 5) {
            return "17134";
        }
        return "";
    }
    
      public void TampilData() {
        if (jComboBox1 != null) {
            tahun = getTahun();
        } else {
            tahun = "";
        }
        ResultSet rs = null;
        try {
            Statement stmt = con.createStatement();
            String sql = "SELECT * FROM `pendaftar`,"
                    + " `prodi`, `tahun` WHERE `pendaftar`.`id_prodi_1` = `prodi`.`id_prodi` "
                    + "AND `pendaftar`.`id_tahun` = `tahun`.`id_tahun`";
            if (!tahun.equals("")) {
                sql += " AND `pendaftar`.`id_tahun` = " + tahun + " ORDER BY `pendaftar`.`id_prodi_1` ASC";
            } else {
                sql += " ORDER BY `pendaftar`.`id_prodi_1` ASC";
            }
            rs = stmt.executeQuery(sql);

            int baris = 0;
            while (rs.next()) {
                baris = rs.getRow();
            }
            dataTable = new String[baris][5];
            int x = 0;
            rs.beforeFirst();
            while (rs.next()) {
                dataTable[x][0] = String.valueOf(rs.getInt("pendaftar.id_pendaftar"));
                dataTable[x][1] = rs.getString("pendaftar.nama_pendaftar");
                dataTable[x][2] = rs.getString("prodi.nama_prodi");
                dataTable[x][4] = rs.getString("tahun.nama_tahun");
                x++;
            }

        } catch (Exception e) {
            System.err.println("Atas" + e);
        }

        rs = null;
        try {
            Statement stmt = con.createStatement();
            String sql = "SELECT * FROM `pendaftar`,"
                    + " `prodi`, `tahun` WHERE `pendaftar`.`id_prodi_2` = `prodi`.`id_prodi` "
                    + "AND `pendaftar`.`id_tahun` = `tahun`.`id_tahun`";
            if (!tahun.equals("")) {
                sql += " AND `pendaftar`.`id_tahun` = " + tahun + " ORDER BY `pendaftar`.`id_prodi_1` ASC";
            } else {
                sql += " ORDER BY `pendaftar`.`id_prodi_1` ASC";
            }
            rs = stmt.executeQuery(sql);
            int x = 0;
            while (rs.next()) {
                dataTable[x][3] = rs.getString("prodi.nama_prodi");
                x++;
            }

            TabelDisplay.setModel(new DefaultTableModel(dataTable, header2));
        } catch (Exception e) {
            System.out.println(e);
        }

    }

    public void SimpanData() {
        if (itemCek()) {
            try {
                String sql = "Insert Into pendaftar VALUES "
                        + "('"+txtnomer.getText()+"','"+txtnama.getText()+"',"
                        + ""+getNamaProdi((String) jComboBox2.getSelectedItem())+","
                        + ""+getNamaProdi((String)jComboBox3.getSelectedItem())+","
                        + ""+txtnomer.getText().substring(0, 5)+")";
                Statement stmt = (Statement) con.createStatement();
                stmt.executeUpdate(sql);
                System.out.println("berhasil");
            } catch (Exception e) {
                System.out.println(e);
            }
            TampilData();
        }else{
            JOptionPane.showConfirmDialog(this, "Pengisian Pagal!!","Peringatan",JOptionPane.CLOSED_OPTION);
        }

    }

    private void hapusData() {

        try {
            String sql = "DELETE FROM `skripsi`.`pendaftar` WHERE `pendaftar`.`id_pendaftar` = \"" + txtnomer.getText() + "\"";
            Statement stmt = con.createStatement();
            stmt.executeUpdate(sql);
            System.out.println("berhasil dihapus");
        } catch (Exception e) {
            System.out.println(e);
        }
        txtnomer.setText("");
        txtnama.setText("");
        jComboBox2.setSelectedIndex(0);
        jComboBox3.setSelectedIndex(0);
        TampilData();
    }

    private void ubahData() {
        try {
            String sql = "UPDATE `skripsi`.`pendaftar` set id_pendaftar = \"" + txtnomer.getText() + "\","
                    + "`nama_pendaftar` = \"" + txtnama.getText() + "\","
                    + "`id_prodi_1` = \"" + getNamaProdi((String) jComboBox2.getSelectedItem()) + "\","
                    + "`id_prodi_2` = \"" + getNamaProdi((String) jComboBox3.getSelectedItem()) + "\""
                    + "WHERE `pendaftar`.`id_pendaftar`= \"" + txtnomer.getText() + "\"";              
            Statement stmt = con.createStatement();
            stmt.executeUpdate(sql);
            System.out.println("berhasil diupdate");
        } catch (Exception e) {
            System.out.println(e);
        }

        txtnomer.setText("");
        txtnama.setText("");
        jComboBox2.setSelectedIndex(0);
        jComboBox3.setSelectedIndex(0);
    
        TampilData();
        
    }
    
   public void prepare() {
        if (jComboBox1 != null) {
            tahun = getTahun();
        } else {
            tahun = "";
        }
        database = new Database();
        ResultSet rs = null;
        try {
            Statement stmt = con.createStatement();
            String sql = "SELECT * FROM `skripsi`.`pendaftar`";
            if (!tahun.equals("")) {
                sql += " WHERE `pendaftar`.`id_tahun` = " + tahun + " ORDER BY `pendaftar`.`id_prodi_1`  ASC";
            } else {
                sql += " ORDER BY `pendaftar`.`id_prodi_1`  ASC";
            }
            rs = stmt.executeQuery(sql);
            int baris = 0;
            while (rs.next()) {
                baris = rs.getRow();
            }

            database.setPendaftar(new String[baris][5]);
            int x = 0;
            rs.beforeFirst();
            while (rs.next()) {
                database.getPendaftar()[x][0] = String.valueOf(rs.getInt("id_pendaftar"));
                database.getPendaftar()[x][1] = rs.getString("nama_pendaftar");
                database.getPendaftar()[x][2] = String.valueOf(rs.getInt("id_prodi_1"));
                database.getPendaftar()[x][3] = String.valueOf(rs.getInt("id_prodi_2"));
                database.getPendaftar()[x][4] = String.valueOf(rs.getInt("id_tahun"));
                x++;
            }
        } catch (Exception e) {
            System.err.println(e);
        }

        rs = null;
        try {
            Statement stmt = con.createStatement();
            rs = stmt.executeQuery("SELECT * FROM `prodi` ORDER BY `id_prodi` ASC");
            int baris = 0;
            while (rs.next()) {
                baris = rs.getRow();
            }

            database.setProdi(new String[baris][3]);
            int x = 0;
            rs.beforeFirst();
            while (rs.next()) {
                database.getProdi()[x][0] = String.valueOf(rs.getInt("id_prodi"));
                database.getProdi()[x][1] = rs.getString("nama_prodi");
                x++;
            }
        } catch (Exception e) {
            System.err.println(e);
        }
        database.setDataTable(dataTable);

        for (int i = 0; i < database.getProdi().length; i++) {
            rs = null;
            try {
                Statement stmt = con.createStatement();
                rs = stmt.executeQuery(getSql(database.getProdi()[i][0]));

                while (rs.next()) {
                    database.getProdi()[i][2] = rs.getString("jumlah");
                }

            } catch (Exception e) {
                System.out.println(e);
            }
        }

    }

    public String getSql(String prodi) {
        String sql = "SELECT COUNT(*) as `jumlah` from `pendaftar` "
                + "WHERE (`id_prodi_1` = " + prodi + " OR `id_prodi_2` = " + prodi + ")";
        if (!tahun.equals("")) {
            sql += " AND `pendaftar`.`id_tahun` = " + tahun + "";
        }
        return sql;
    }

    public String getNamaProdi(String kode) {

        for (int i = 0; i < database.getProdi().length; i++) {
            if (database.getProdi()[i][1].equals(kode)) {
                return database.getProdi()[i][0];
            }
        }

        return "0";
    }

    public boolean itemCek() {
        return !txtnama.getText().isEmpty() && !txtnomer.getText().isEmpty()
                && jComboBox1.getSelectedIndex() != 0;
    }

        
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        jPanel1 = new javax.swing.JPanel();
        jComboBox1 = new javax.swing.JComboBox();
        jButton1 = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        txtnomer = new javax.swing.JTextField();
        txtnama = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jComboBox2 = new javax.swing.JComboBox();
        jComboBox3 = new javax.swing.JComboBox();
        jScrollPane2 = new javax.swing.JScrollPane();
        TabelDisplay = new javax.swing.JTable();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jButton4 = new javax.swing.JButton();
        jButton5 = new javax.swing.JButton();
        jButton6 = new javax.swing.JButton();
        jButton7 = new javax.swing.JButton();
        jLabel5 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "SEMUA DATA", "SPMU 2009", "SPMU 2010", "SPMU 2011", "SPMU 2012", "SPMU 2013" }));

        jButton1.setText("PILIH");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jLabel1.setText("NOMER UJIAN");

        jLabel2.setText("NAMA PENDAFTAR");

        jLabel3.setText("PILIHAN PRODI 1");

        jLabel4.setText("PILIHAN PRODI 2");

        jComboBox2.setModel(new javax.swing.DefaultComboBoxModel(new String[] { " ", "PEND. MATEMATIKA, S1", "PEND. FISIKA, S1", "PEND. KIMIA, S1", "PEND. BIOLOGI, S1", "PEND. IPA, S1", "PEND. TEKNIK BANGUNAN, S1", "PEND. TEKNIK MESIN, S1", "PEND. TEKNIK OTOMOTIF, S1", "PEND. TEKNIK ELEKTRO, S1", "PEND. TIK, S1", "TEKNOLOGI PENDIDIKAN, S1", "PEND. LUAR SEKOLAH, S1", "BIMBINGAN DAN KONSELING, S1", "PEND. GURU SEKOLAH DASAR, S1", "PG PAUD, S1", "PBSI, S1 (BAHASA INDONESIA)", "PEND. BAHASA INGGRIS, S1", "PEND. BAHASA PRANCIS, S1", "PEND. BAHASA JEPANG, S1", "PEND. BAHASA ARAB, S1", "PEND. BAHASA MANDARIN, S1", "PEND. SENI RUPA, S1", "PEND. SENDRATASIK, S1 (SENI TARI)", "PEND. SENDRATASIK, S1 (SENI MUSIK)", "PEND. BAHASA JAWA, S1", "PEND. SEJARAH, S1", "PEND. GEOGRAFI, S1", "PPKN, S1", "PEND. SOSIOLOGI DAN ANTROPOLOGI, S1", "P K K, S1 (TATA BUSANA)", "P K K, S1 (TATA BOGA)", "PEND. TATA KECANTIKAN, S1", "PJKR, S1", "PJKR, S1 (PGPJSD)", "PEND. KEPELATIHAN OLAHRAGA, S1", "PEND. EKONOMI, S1 (AKUNTANSI)", "PEND. EKONOMI, S1 (KOPERASI)", "PEND. EKONOMI, S1 (ADM PERKANTORAN)", "MATEMATIKA, S1", "STATISTIKA TERAPAN DAN KOMPUTASI, D3", "FISIKA, S1", "KIMIA, S1", "BIOLOGI, S1", "TEKNIK INFORMATIKA, S1", "TEKNIK SIPIL, S1", "TEKNIK SIPIL, D3", "TEKNIK ARSITEKTUR, S1", "TEKNIK MESIN, S1", "TEKNIK MESIN, D3", "TEKNIK KIMIA, S1", "TEKNIK KIMIA, D3", "TEKNIK ELEKTRO, D3", "ILMU KEOLAHRAGAAN, S1", "KESEHATAN MASYARAKAT, S1", "PSIKOLOGI, S1", "SASTRA INDONESIA, S1", "SASTRA INGGRIS, S1", "SASTRA PERANCIS, S1", "SENI RUPA, S1", "SENI RUPA, S1 (DEKOMVIS)", "DESAIN KOMUNIKASI VISUAL, D3", "SASTRA JAWA, S1", "ILMU SEJARAH, S1", "GEOGRAFI, S1", "SURVEY DAN PEMETAAN WILAYAH, D3", "ILMU POLITIK, S1", "AKUNTANSI, S1", "AKUNTANSI, D3", "MANAJEMEN, S1", "MANAJEMEN PERKANTORAN, D3", "EKONOMI PEMBANGUNAN, S1", "ILMU HUKUM, S1" }));

        jComboBox3.setModel(new javax.swing.DefaultComboBoxModel(new String[] { " ", "PEND. MATEMATIKA, S1", "PEND. FISIKA, S1", "PEND. KIMIA, S1", "PEND. BIOLOGI, S1", "PEND. IPA, S1", "PEND. TEKNIK BANGUNAN, S1", "PEND. TEKNIK MESIN, S1", "PEND. TEKNIK OTOMOTIF, S1", "PEND. TEKNIK ELEKTRO, S1", "PEND. TIK, S1", "TEKNOLOGI PENDIDIKAN, S1", "PEND. LUAR SEKOLAH, S1", "BIMBINGAN DAN KONSELING, S1", "PEND. GURU SEKOLAH DASAR, S1", "PG PAUD, S1", "PBSI, S1 (BAHASA INDONESIA)", "PEND. BAHASA INGGRIS, S1", "PEND. BAHASA PRANCIS, S1", "PEND. BAHASA JEPANG, S1", "PEND. BAHASA ARAB, S1", "PEND. BAHASA MANDARIN, S1", "PEND. SENI RUPA, S1", "PEND. SENDRATASIK, S1 (SENI TARI)", "PEND. SENDRATASIK, S1 (SENI MUSIK)", "PEND. BAHASA JAWA, S1", "PEND. SEJARAH, S1", "PEND. GEOGRAFI, S1", "PPKN, S1", "PEND. SOSIOLOGI DAN ANTROPOLOGI, S1", "P K K, S1 (TATA BUSANA)", "P K K, S1 (TATA BOGA)", "PEND. TATA KECANTIKAN, S1", "PJKR, S1", "PJKR, S1 (PGPJSD)", "PEND. KEPELATIHAN OLAHRAGA, S1", "PEND. EKONOMI, S1 (AKUNTANSI)", "PEND. EKONOMI, S1 (KOPERASI)", "PEND. EKONOMI, S1 (ADM PERKANTORAN)", "MATEMATIKA, S1", "STATISTIKA TERAPAN DAN KOMPUTASI, D3", "FISIKA, S1", "KIMIA, S1", "BIOLOGI, S1", "TEKNIK INFORMATIKA, S1", "TEKNIK SIPIL, S1", "TEKNIK SIPIL, D3", "TEKNIK ARSITEKTUR, S1", "TEKNIK MESIN, S1", "TEKNIK MESIN, D3", "TEKNIK KIMIA, S1", "TEKNIK KIMIA, D3", "TEKNIK ELEKTRO, D3", "ILMU KEOLAHRAGAAN, S1", "KESEHATAN MASYARAKAT, S1", "PSIKOLOGI, S1", "SASTRA INDONESIA, S1", "SASTRA INGGRIS, S1", "SASTRA PERANCIS, S1", "SENI RUPA, S1", "SENI RUPA, S1 (DEKOMVIS)", "DESAIN KOMUNIKASI VISUAL, D3", "SASTRA JAWA, S1", "ILMU SEJARAH, S1", "GEOGRAFI, S1", "SURVEY DAN PEMETAAN WILAYAH, D3", "ILMU POLITIK, S1", "AKUNTANSI, S1", "AKUNTANSI, D3", "MANAJEMEN, S1", "MANAJEMEN PERKANTORAN, D3", "EKONOMI PEMBANGUNAN, S1", "ILMU HUKUM, S1" }));

        TabelDisplay.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Nomer Ujian", "Nama Peserta", "Program Studi 1", "Program Studi 2"
            }
        ));
        TabelDisplay.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                TabelDisplayMouseClicked(evt);
            }
        });
        TabelDisplay.addAncestorListener(new javax.swing.event.AncestorListener() {
            public void ancestorMoved(javax.swing.event.AncestorEvent evt) {
            }
            public void ancestorAdded(javax.swing.event.AncestorEvent evt) {
                TabelDisplayAncestorAdded(evt);
            }
            public void ancestorRemoved(javax.swing.event.AncestorEvent evt) {
            }
        });
        jScrollPane2.setViewportView(TabelDisplay);

        jButton2.setText("SIMPAN");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jButton3.setText("UBAH");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        jButton4.setText("HAPUS");
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });

        jButton5.setText("KELUAR");
        jButton5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton5ActionPerformed(evt);
            }
        });

        jButton6.setText("MENU UTAMA");

        jButton7.setText("Analisis");
        jButton7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton7ActionPerformed(evt);
            }
        });

        jLabel5.setText("INPUT DATA SPMU");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(42, 42, 42)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGap(11, 11, 11)
                                .addComponent(jLabel1)
                                .addGap(90, 90, 90)
                                .addComponent(jLabel2)
                                .addGap(100, 100, 100)
                                .addComponent(jLabel3)
                                .addGap(76, 76, 76)
                                .addComponent(jLabel4))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGap(2, 2, 2)
                                .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(29, 29, 29)
                                .addComponent(jButton1))))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(31, 31, 31)
                        .addComponent(txtnomer, javax.swing.GroupLayout.PREFERRED_SIZE, 115, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(35, 35, 35)
                        .addComponent(txtnama, javax.swing.GroupLayout.PREFERRED_SIZE, 154, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, 207, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(26, 26, 26)
                        .addComponent(jComboBox3, javax.swing.GroupLayout.PREFERRED_SIZE, 187, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(42, 42, 42)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 633, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jButton4)
                                    .addComponent(jButton3)
                                    .addComponent(jButton2)))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jButton6)
                                .addGap(196, 196, 196)
                                .addComponent(jButton7)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 216, Short.MAX_VALUE)
                                .addComponent(jButton5)
                                .addGap(82, 82, 82)))))
                .addContainerGap(120, Short.MAX_VALUE))
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(324, 324, 324)
                .addComponent(jLabel5)
                .addContainerGap(479, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel5)
                .addGap(26, 26, 26)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton1)
                    .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(29, 29, 29)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(jLabel1)
                    .addComponent(jLabel3)
                    .addComponent(jLabel4))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtnomer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtnama, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jComboBox3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(46, 46, 46)
                        .addComponent(jButton2)
                        .addGap(28, 28, 28)
                        .addComponent(jButton3)
                        .addGap(27, 27, 27)
                        .addComponent(jButton4))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 475, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 35, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton6)
                    .addComponent(jButton7)
                    .addComponent(jButton5))
                .addContainerGap())
        );

        jScrollPane1.setViewportView(jPanel1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 798, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 729, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
// TODO add your handling code here:
    TampilData();
}//GEN-LAST:event_jButton1ActionPerformed

private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton7ActionPerformed
// TODO add your handling code here:
    prepare();
    analisis Analisis = new analisis();
    Analisis.setDatabase(database);
    Analisis.setVisible(true);
    this.dispose();
}//GEN-LAST:event_jButton7ActionPerformed

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
// TODO add your handling code here:
    SimpanData();
    txtnomer.setText("");
    txtnama.setText("");
    jComboBox2.setSelectedIndex(0);
    jComboBox3.setSelectedIndex(0);
}//GEN-LAST:event_jButton2ActionPerformed

private void TabelDisplayAncestorAdded(javax.swing.event.AncestorEvent evt) {//GEN-FIRST:event_TabelDisplayAncestorAdded
// TODO add your handling code here:
TampilData();
}//GEN-LAST:event_TabelDisplayAncestorAdded

private void TabelDisplayMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_TabelDisplayMouseClicked
// TODO add your handling code here:
  //int row = TabelDisplay.getSelectedRow();
  //String id_pendaftar = TabelDisplay.getValueAt(row, 0).toString();
  //String nama_pendaftar = TabelDisplay.getValueAt(row, 1).toString();
  //String id_prodi_1 = TabelDisplay.getValueAt(row, 2).toString();
   //String id_prodi_2 = TabelDisplay.getValueAt(row, 3).toString();

   //txtnomer.setText(id_pendaftar);
   //txtnama.setText(nama_pendaftar);
    //jComboBox2.setSelectedItem(id_prodi_1);
  //jComboBox3.setSelectedItem(id_prodi_2);
}//GEN-LAST:event_TabelDisplayMouseClicked

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
// TODO add your handling code here:
ubahData();
        
}//GEN-LAST:event_jButton3ActionPerformed

private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
// TODO add your handling code here:
hapusData();
}//GEN-LAST:event_jButton4ActionPerformed

private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed
// TODO add your handling code here:
System.exit(0);
}//GEN-LAST:event_jButton5ActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(input.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(input.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(input.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(input.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new input().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTable TabelDisplay;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton5;
    private javax.swing.JButton jButton6;
    private javax.swing.JButton jButton7;
    private javax.swing.JComboBox jComboBox1;
    private javax.swing.JComboBox jComboBox2;
    private javax.swing.JComboBox jComboBox3;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTextField txtnama;
    private javax.swing.JTextField txtnomer;
    // End of variables declaration//GEN-END:variables
}
